package com.naya.lib_log.logger

import android.util.Log

/***
 * @Author liumiaojiang
 * @description IVideo
 * @date 2025/2/24
 */
class FileLogger: ILogger {
    private var isDebug = true //是否debug
    private var TAG = "" //默认TAG
    private var level = LoggerLevel.Debug //默认级别
    private var url = "" //保存地址
    private var loggerFormat = "%s====>%s"
    override fun v(tag: String, log: String) {
        if(isDebug && level.value >= LoggerLevel.Verbose.value){
            val log = String.format(loggerFormat,tag,log)
            Log.v(TAG, "打印在磁盘：$log")

        }
    }
    override fun d(tag: String, log: String) {
        if(isDebug && level.value >= LoggerLevel.Debug.value){
            val log = String.format(loggerFormat,tag,log)
            Log.d(TAG, "打印在磁盘：$log")
        }
    }



    override fun i(tag: String, log: String) {
        if(isDebug && level.value >= LoggerLevel.Info.value){
            val log = String.format(loggerFormat,tag,log)
            Log.i(TAG, "打印在磁盘：$log")
        }
    }

    override fun w(tag: String, log: String) {
        if(isDebug && level.value >= LoggerLevel.Warn.value){
            val log = String.format(loggerFormat,tag,log)
            Log.d(TAG, "打印在磁盘：$log")
        }
    }

    override fun e(tag: String, log: String) {
        if(isDebug && level.value >= LoggerLevel.Error.value){
            val log = String.format(loggerFormat,tag,log)
            Log.e(TAG, "打印在磁盘：$log")
        }
    }

    override fun setDebug(isDebug: Boolean) {
        this.isDebug = isDebug
    }

    override fun setLogTAG(TAG: String) {
        this.TAG = TAG
    }

    override fun setLoggerLevel(level: LoggerLevel) {
        this.level = level
    }

    override fun setSaveUrl(url: String) {
        this.url = url
    }
}